package com.longcai.service.fuyoupay.impl;

import java.util.Date;
import java.util.UUID;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.longcai.entity.payment.fuyou.request.ClyjFuyouRecharge;
import com.longcai.fenzhuang.fuyou.BaseResponse;
import com.longcai.fenzhuang.fuyou.FuyouCommonPortMethod;
import com.longcai.mapper.fuyoupay.ClyjFuyouRechargeMapper;
import com.longcai.service.fuyoupay.ClyjFuyouRechargeService;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LWK
 * @since 2019-04-16
 */
@Service
public class ClyjFuyouRechargeServiceImpl extends ServiceImpl<ClyjFuyouRechargeMapper, ClyjFuyouRecharge> implements ClyjFuyouRechargeService {

	@Override
	public ClyjFuyouRecharge checkout(JSONObject params) {
		ClyjFuyouRecharge cfr=new ClyjFuyouRecharge();
		cfr.setId(UUID.randomUUID().toString().replace("-", ""));
		cfr.setLoginId(params.getString("loginId"));
		cfr.setAmt(params.getString("amt"));
		cfr.setBackNotifyUrl(params.getString("backNotifyUrl"));
		cfr.setPageNotifyUrl(params.getString("pageNotifyUrl"));
		cfr.setRechargeTime(new Date());
		FuyouCommonPortMethod fcpm=new FuyouCommonPortMethod();
		BaseResponse r = fcpm.recharge(cfr);
		if(r!=null&r.getRespCode().equals("0000")){
			return cfr;
		}
		return null;
	}

}
